import request from "./request.js";

let baseUrl
if (import.meta.env.MODE === 'production') {
    baseUrl = 'http://42.193.218.104:3001'
} else {
    baseUrl = 'http://localhost:3001'
}
export const getQuestionList = (page = 1, pageSize = 10) => {
    return request({
        url: baseUrl + `/api/question`,
        method: "GET",
        params: {
            page: page,
            pageSize: pageSize
        }
    })
}
export const getQuestionDetail = (id) => {
    return request({
        url: baseUrl + `/api/question/${id}`,
        method: "GET",
    });
}
export const getQuestionStatListService = (id, page = 1, pageSize = 20) => {
    return request({
        url: baseUrl + `/api/stat/${id}/?page=${page}&pageSize=${pageSize}`,
        method: "GET",
    });
}
export const getStarQuestionList = (data, page = 1, pageSize = 10) => {
    const {keyword, isDeleted, isStar} = data
    return request({
        url: baseUrl + `/api/question`,
        method: "GET",
        params: {
            keyword: keyword,
            isStar: isStar,
            page: page,
            isDeleted: isDeleted,
            pageSize: pageSize
        }
    })
}
export const deleteQuestionItem = (id) => {
    return request({
        url: baseUrl + `/api/question/${id}`,
        method: "PATCH",
        data : {
            isDeleted:true
        }
    });
}
export const getMyQuestionDetail = (id) => {
    return request({
        url: baseUrl + `/api/myQuestion/${id}`,
        method: "GET",
    });
}
